#!/bin/bash -e

function info() {
echo Usage: `basename $0` 'in.vcf'
exit 2
}

while getopts  ":p:f:" opt; do
	case  $opt  in
		p) out_prefix=$OPTARG;;
		f) suffix=$OPTARG;;
		*) info;;
	esac
done
shift $(($OPTIND - 1))


if [ $# -lt 1 ]; then info; fi

. $var

names=`grep '^#CHROM' $1|cut -f10-`

for name in $names; do
    names1="$names1 \"GEN[$name].GT\""
done

for name in $names; do
    names1="$names1 \"GEN[$name].AD\""
done

echo extractField
# $java_run/snpsift filter $1 "" > 
# $java_run/snpsift extractField -e "." $1 "GEN[*].GT" "GEN[*].AD" "GEN[*].DP"|sed "1d; 2i#$names" > $out_prefix.fields.txt 

names=`grep '^#CHROM' $1|cut -f10-`
$java_run/snpsift extractField -e "." $1 "GEN[*].DP"|sed "1d; 2i#$names" > $out_prefix.fields.txt 
# $java_run/snpsift extractField -e "." $1 $names1 > $out_prefix.fields.txt 

# GEN[*].GT
# GEN[3].GL[*]

# SnpEff 'ANN' fields:
# "ANN[*].ALLELE" (alias GENOTYPE)
# "ANN[*].EFFECT" (alias ANNOTATION): Effect in Sequence ontology terms (e.g. 'missense_variant', 'synonymous_variant', 'stop_gained', etc.)
# "ANN[*].IMPACT:" { HIGH, MODERATE, LOW, MODIFIER }
# "ANN[*].GENE:" Gene name (e.g. 'PSD3')
# "ANN[*].GENEID:" Gene ID
# "ANN[*].FEATURE
# " ANN[*].FEATUREID (alias TRID: Transcript ID)
# "ANN[*].BIOTYPE:" Biotype, as described by the annotations (e.g. 'protein_coding')
# "ANN[*].RANK:" Exon or Intron rank (i.e. exon number in a transcript)
# "ANN[*].HGVS_C" (alias HGVS_DNA, CODON): Variant in HGVS (DNA) notation
# "ANN[*].HGVS_P" (alias HGVS, HGVS_PROT, AA): Variant in HGVS (protein) notation
# "ANN[*].CDNA_POS" (alias POS_CDNA)
# "ANN[*].CDNA_LEN" (alias LEN_CDNA)
# "ANN[*].CDS_POS" (alias POS_CDS)
# "ANN[*].CDS_LEN" (alias LEN_CDS)
# "ANN[*].AA_POS" (alias POS_AA)
# "ANN[*].AA_LEN" (alias LEN_AA)
# "ANN[*].DISTANCE"
# "ANN[*].ERRORS" (alias WARNING, INFOS)

. $cmd_done